home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10388 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: news.sover.net!news
  2. From: mountain@sover.net (Steve Mount)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: A Simple Question From A Beginner (Please Help)
  5. Date: 17 Mar 1996 14:49:25 GMT
  6. Organization: SoVerNet, Inc.
  7. Message-ID: <4ih8pl$680@thrush.sover.net>
  8. References: <4i26gm$6th@news.bellglobal.com>
  9. NNTP-Posting-Host: pm0a6.mid.sover.net
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=US-ASCII
  12. X-Newsreader: WinVN 0.99.7
  13.  
  14. In article <4i26gm$6th@news.bellglobal.com>, dlowe@pathcom.com says...
  15. >
  16. >
  17. >This should be a simple thing to execute but for some reason I can not
  18. >get it to work.
  19. >
  20. >
  21. >What I would like to do is execute something like a SHELL command.
  22. >What I would like to do in C or C++ is the equivelent to typing the
  23. >following at the Win NT command line:
  24. >
  25. >
  26. >    sendmail dlowe@pathcom.com < mail.txt
  27. >
  28. >I have tried the following code:
  29. >
  30. >   _spawnl( _P_WAIT, "sendmail.exe", "dlowe@pathcom.com < mail.txt", 
  31. >             NULL);   
  32. >
  33. >and 
  34. >
  35. >
  36. >    args[0] = "child";
  37. >    args[1] = "dlowe@pathcom.com < c:\\notes\\data\\clustrep.txt";
  38. >    args[2] = NULL;
  39. >    args[3] = NULL;
  40. >    .
  41. >    .
  42. >    .
  43. >   _spawnvp( _P_OVERLAY, "c:\\Sendmail\\Sendmail.exe", args );
  44. >
  45. >
  46. >My problem ranges from nothing happends to Sendmail not see the
  47. >parameters  properly.
  48. >
  49. >Any help would be greatly appreaciated.
  50.  
  51. I think your problem is that the redirection is not being interpreted - 
  52. normally the command interpreter (whether command.com or a shell in Unix)
  53. takes care of the redirection.  I think what you want to use is the
  54. system() function.  Try it out.  It offers less control, but does spawn
  55. a command interpreter to take care of your command line, and does the
  56. redirection, too.
  57.  
  58. +============================================================================+
  59. | Steve Mount, Software Engineer            Work: sjjm@hawkeye.idx.com       |
  60. | CIS: 73720,3404  MSN: S_Mountain          Home: mountain@sover.net         |
  61. | AOL: Mountain                                                              |
  62. | WWW: http://www.sover.net/~mountain/      "Fight, Win, Prevail!"           |
  63. +============================================================================+
  64.  
  65.